package airhockey.spel;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;

public class Middenlijn {
	private int xStart, yStart, xStop, yStop;
	private int widthFrame, heightFrame;
	private Paint paint;
	
	public Middenlijn(int widthFrame, int heightFrame) {
		this.widthFrame = widthFrame;
		this.heightFrame = heightFrame;
		
		paint = new Paint();
		paint.setStrokeWidth(3);
		paint.setColor(Color.RED);
	}
	
	/**
	 * Teken de middenlijn op het speelveld
	 * @param canvas
	 */
	public void draw(Canvas canvas) {
		berekenCoordinaten(canvas);
		
		//teken de horizontale lijn
		DashPathEffect dashPath = new DashPathEffect(new float[]{10,10}, 1);
		paint.setPathEffect(dashPath);
		canvas.drawLine(xStart, yStart, xStop, yStop, paint);
		
		//teken de cirkels
		paint.setStyle(Paint.Style.FILL_AND_STROKE);
		canvas.drawCircle(widthFrame/2, heightFrame/2, 10, paint);
		paint.setStyle(Paint.Style.STROKE);
		paint.setPathEffect(null);
		canvas.drawCircle(widthFrame/2, heightFrame/2, 25, paint);
	}

	/**
	 * Bereken de coordinaten van de middenlijn
	 * @param canvas
	 */
	private void berekenCoordinaten(Canvas canvas) {
		this.xStart = 0;
		this.yStart = heightFrame/2;
		this.xStop = widthFrame;
		this.yStop = heightFrame/2;
	}
}
